/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mycompany.action;

import com.opensymphony.xwork2.ActionSupport;
import com.mycompany.dao.StudentDAO;
import com.mycompany.entity.Student;

/**
 *
 * @Created on 16-Mar-2009, 16:33:29
 * @author Wenbo.Sun
 */
public class AddStudentAction extends ActionSupport {
    private static final long serialVersionUID = 1L;

    private String number;
    private String name;
    private StudentDAO studentDAO;

    public AddStudentAction(StudentDAO studentDAO) {
        this.studentDAO = studentDAO;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    @Override
    public String execute() throws Exception {
        Student student = new Student(number, name);
        studentDAO.save(student);
        return SUCCESS;
    }
}
